<!-- 项目专属信息 -->
<template>
  <TCollapse title="项目专属信息">
    <iframe :src="proprietaryUrl" scrolling="no" width="100%" :height="proiprHeight" frameborder="0" />
  </TCollapse>
</template>
<script>

import TCollapse from '@/components/basic/TCollapse.vue'
const config = [
  {
    type: ['M'], // M = IT投资类类项目
    iframeUrl: 'design/proprietaryInfo',
    iframeHeight: 'proiprHeight'
  },
  {
    type: ['A', 'B', 'C', 'G', 'Z', 'T', 'Q', 'W', 'Y', 'S', 'J','F','L'], // A = 铁塔类项目, B = 室分类项目, C = 传输类项目, G = 微姑类项目, Z = 整体项目
    iframeUrl: 'design/projectProprietaryInfo',
    iframeHeight: 'proiprHeight'
  }
]
export default {
  name: 'JnProprietaryDetail',
  components: { TCollapse },
  props: {
    prjId: {
      type: String,
      default: '',
      required: true
    },
    prjType: {
      type: String,
      required: true
    },
    secondaryType: {
      type: String
    }
  },
  data() {
    return {
      proiprHeight: ''
    }
  },
  computed: {
    currentConfig() {
      return config.find(item => item.type.includes(this.prjType || 'M'))
    },
    proprietaryUrl() {
      return `${process.env.VUE_APP_JUNNAN_IFRAME_URL}${this.currentConfig.iframeUrl}?prjId=${this.prjId}&secondaryType=${this.secondaryType}`
    }
  },
  async created() {
    window.addEventListener('message', (event) => {
      const base_url = ''
      if (event.origin === base_url) {
        return
      }
      if (event.data.type === this.currentConfig.iframeHeight) {
        this.proiprHeight = event.data.data
      }
    })
  }
}
</script>

<style scoped lang='scss'>
</style>
